feat: add dedicated Markdown Viewer Editor Window#39
Open
Dheolarh wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a dedicated Unity EditorWindow (MarkdownWindow) for viewing markdown files independently of the Inspector, including menu access and editor hooks to open markdown assets directly in the window.
Changes:
- Introduces
MarkdownWindowEditorWindow with toolbar controls, selection sync, and drag-and-drop loading. - Adds
[OnOpenAsset]handling so double-clicking.md/.markdownopens in the viewer window. - Adds auto-reload behavior to refresh the displayed markdown when the underlying asset changes.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| Editor/Scripts/MarkdownWindow.cs | New EditorWindow implementation for standalone markdown viewing, selection sync, drag/drop loading, and auto-reload. |
| Editor/Scripts/MarkdownWindow.cs.meta | Adds the Unity .meta file for the new script asset. |
Files not reviewed (1)
- Editor/Scripts/MarkdownWindow.cs.meta: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1
to
+2
| fileFormatVersion: 2 | ||
| guid: ecd1fe6ba17648143a9f5dc9db49ae2a No newline at end of file |
Comment on lines
+10
to
+14
| private TextAsset mMarkdownFile; | ||
| private string mLoadedContent; | ||
| private MarkdownViewer mViewer; | ||
| private Vector2 mScrollPosition; | ||
| private bool mSyncSelection = true; |
Comment on lines
+78
to
+82
| // Auto-reload if file contents changed on disk | ||
| if (mMarkdownFile != null && mMarkdownFile.text != mLoadedContent) | ||
| { | ||
| ReloadCurrentFile(); | ||
| } |
Comment on lines
+119
to
+122
| var path = AssetDatabase.GetAssetPath(mMarkdownFile); | ||
| mLoadedContent = mMarkdownFile.text; | ||
| var skin = Preferences.DarkSkin ? mSkinDark : mSkinLight; | ||
| mViewer = new MarkdownViewer(skin, path, mLoadedContent, () => position.width); |
Comment on lines
+124
to
+128
| else | ||
| { | ||
| mViewer = null; | ||
| mLoadedContent = null; | ||
| } |
Comment on lines
+235
to
+254
| DragAndDrop.visualMode = DragAndDropVisualMode.Copy; | ||
|
|
||
| if (evt.type == EventType.DragPerform) | ||
| { | ||
| DragAndDrop.AcceptDrag(); | ||
| foreach (var draggedObject in DragAndDrop.objectReferences) | ||
| { | ||
| if (draggedObject is TextAsset textAsset) | ||
| { | ||
| var path = AssetDatabase.GetAssetPath(textAsset); | ||
| var ext = Path.GetExtension(path).ToLower(); | ||
| if (ext == ".md" || ext == ".markdown") | ||
| { | ||
| LoadMarkdownFile(textAsset); | ||
| Repaint(); | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a dedicated
MarkdownWindow(Editor Window) that allows developers to view and read markdown files independently of their Inspector selections.Why this is needed
Previously, markdown files could only be previewed directly inside the Inspector window. However, when developers are setting up scenes, editing components, or interacting with Hierarchy objects, the Inspector is overridden by the selected GameObjects, preventing them from reading markdown setup/guide files simultaneously.
Key Features
Window -> Markdown Viewer Window.[OnOpenAsset]): Double-clicking a.mdor.markdownfile in the Project window automatically opens it in this window instead of launching an external text editor.